I have this in my Child Component. I want to use showTab state in its parent component. How do i send it to its parent?
let enable = false;
if (value) {
enable = true;
}
this.state = {
showTab: enable
};
handleChangeTab = ()=>{
this.setState({
showTab: !this.state.showTab
});
}
You need to Lift State Up:
constructor(props) {
super(props);
this.handleChangeTab = this.handleChangeTab.bind(this);
let enable = false;
}
if (value) enable = true;
this.state = { showTab: enable };
handleChangeTab = () => {
this.setState({showTab: !this.state.showTab});
}